
package com.apes.fn.scm.settlePolicy;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.fn.scm.contract.FnContract;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 赋能结算政策
 * @author bbyford
 * @create 2019-12-19
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name=SettlePolicy.CONST_TABLE_NAME)
public class SettlePolicy extends Model {
    public static final String CONST_TABLE_NAME = "fn_settle_policy";




    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "赋能结算政策编码", padding = 8)
    @Comment("编码")
    private String id;



    @Name
    @Comment("描述")
    @Column(name = "description", length = 255, nullable = false)
    private String description;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "contract_id", referencedColumnName = "id", nullable = false)
    @Comment("赋能合同")
    private FnContract contract;


    @Comment("首次结算日期")
    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "first_settlement_date", nullable = false)
    private Date firstSettlementDate;


    @Comment("有效期起")
    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "valid_from", nullable = false)
    private Date validFrom;


    @Comment("有效期止")
    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "valid_period", nullable = false)
    private Date validPeriod;



}


